package main

type Conf struct {
	Db struct {
		Host string
    	Port string
    	Database string
    	User string
    	Password string
    	Charset string
		SetMaxOpenConns int
		SetMaxIdleConns int
	}
	Redis struct {
		Host string
		Port string
		Password string
		Database int
	}
	Normal struct{
		UidOnline string
	}
}

func (Config *Conf) InitDb(DbConfig *map[string]interface{}){
	// DB Config.(Recommend to use configuration file to import)
	*DbConfig = map[string]interface{}{
		// Default database configuration
		"Default": "mysql_dev",
		// (Connection pool) Max open connections, default value 0 means unlimit.
		"SetMaxOpenConns": Config.Db.SetMaxOpenConns,
		// (Connection pool) Max idle connections, default value is 1.
		"SetMaxIdleConns": Config.Db.SetMaxIdleConns,
	
		// Define the database configuration character "mysql_dev".
		"Connections":map[string]map[string]string{
			"mysql_dev": map[string]string{
	                    "host":     Config.Db.Host,
	                    "username": Config.Db.User,
	                    "password": Config.Db.Password,
	                    "port":     Config.Db.Port,
	                    "database": Config.Db.Database,
	                    "charset":  Config.Db.Charset,
	                    "protocol": "tcp",
	                    "prefix":   "",      // Table prefix
	                    "driver":   "mysql", // Database driver(mysql,sqlite,postgres,oracle,mssql)
	                },
		},
	}

}